﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using eShop.Model;

namespace eShop.Business
{
    public class ProductNameCompare : IComparer<Product>, IComparer
    {
        #region IComparer<Product> Members

        public int Compare(Product x, Product y)
        {
            return x.ProductName.CompareTo(y.ProductName);
        }

        #endregion

        public int Compare(object x, object y)
        {
            return Compare((Product)x, (Product)y);
        }
    }

    public class ProductNameDescendingCompare : IComparer<Product>, IComparer
    {
        #region IComparer<Product> Members

        public int Compare(Product x, Product y)
        {
            return y.ProductName.CompareTo(x.ProductName);
        }

        #endregion

        public int Compare(object x, object y)
        {
            return Compare((Product)x, (Product)y);
        }
    }

    public class ProductBrandCompare : IComparer<Product>, IComparer
    {

        #region IComparer<Product> Members

        public int Compare(Product x, Product y)
        {
            return x.Brand.BrandName.CompareTo(y.Brand.BrandName);
        }

        #endregion

        public int Compare(object x, object y)
        {
            return Compare((Product)x, (Product)y);
        }
    }

    public class ProductBrandDescendingCompare : IComparer<Product>
    {
        #region IComparer<Product> Members

        public int Compare(Product x, Product y)
        {
            return y.Brand.BrandName.CompareTo(x.Brand.BrandName);
        }

        #endregion

        public int Compare(object x, object y)
        {
            return Compare((Product)x, (Product)y);
        }
    }

    public class ProductDisplayOrderCompare : IComparer<Product>, IComparer
    {
        #region IComparer<Product> Members

        public int Compare(Product x, Product y)
        {
            return x.DisplayOrder.CompareTo(y.DisplayOrder);
        }

        #endregion

        public int Compare(object x, object y)
        {
            return Compare((Product)x, (Product)y);
        }
    }

    public class ProductDisplayOrderDescendingCompare : IComparer<Product>, IComparer
    {
        #region IComparer<Product> Members

        public int Compare(Product x, Product y)
        {
            return y.DisplayOrder.CompareTo(x.DisplayOrder);
        }

        #endregion

        public int Compare(object x, object y)
        {
            return Compare((Product)x, (Product)y);
        }
    }

    public class ProductPriceCompare : IComparer<Product>, IComparer
    {
        #region IComparer<Product> Members

        public int Compare(Product x, Product y)
        {
            return x.ProductPrice.CompareTo(y.ProductPrice);
        }

        #endregion

        public int Compare(object x, object y)
        {
            return Compare((Product)x, (Product)y);
        }
    }

    public class ProductPriceDescendingCompare : IComparer<Product>, IComparer
    {
        #region IComparer<Product> Members

        public int Compare(Product x, Product y)
        {
            return y.ProductPrice.CompareTo(x.ProductPrice);
        }

        #endregion

        public int Compare(object x, object y)
        {
            return Compare((Product)x, (Product)y);
        }
    }

    public class ProductIdCompare : IComparer<Product>, IComparer
    {

        #region IComparer<Product> Members

        public int Compare(Product x, Product y)
        {
            return x.ProductId.CompareTo(y.ProductId);
        }

        #endregion

        public int Compare(object x, object y)
        {
            return Compare((Product)x, (Product)y);
        }
    }
}
